<?php
namespace Home\Controller;

class LoginController extends HomeBaseController
{
   
    public function index()
    {
        $this->display('login/index');
    }
    
    /**
     * 密码登录
     * @param unknown $uid  $paswd
     */
    public function userLogin()
    {
        $account=I('account','');
        $paswd=I('passwd','');
        if(empty($account) || empty($paswd)) {
            $this->ajaxReturn(array('status'=>'2','msg' => '登录用户和密码不能为空！'));//0错误，1成功
            exit;
        }
        $dao=M();
        $user=$dao->query("SELECT id,account,protype FROM wx_user_acc WHERE paswd='".$paswd."' AND (mobile='".$account."' OR account='".$account."') limit 1");
        if(empty($user)){
            $this->ajaxReturn(array('status'=>'2','msg' => '用户名或密码错误，请重新登录！'));//0错误，1成功
            exit;
        }
        session('id', $user[0]['id']);
        session('account', $user[0]['account']);
        session('protype', $user[0]['protype']);
        $this->ajaxReturn(array('status'=>'1','redirect' => U("Index/index"),'msg'=>'登录成功,请稍候......'));//0错误，1成功
    }
 
    public function logout(){
        session('id',null);
        session('account',null);
        redirect(U('Index/index'));
    }
    
    public function forget(){
        $this->display('login/forget');
    }
    
}